package sanshui.system.trade.factory.notify;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class TradeSysNotifyService {

    private final Map<String, TradeSysNotify> notifyMap = new HashMap<>();

    @Autowired
    public TradeSysNotifyService(List<TradeSysNotify> notifies) {
        for (TradeSysNotify notify : notifies) {
            notifyMap.put(notify.getNotifyChannel(), notify);
        }
    }

    public boolean sendNotify(TradeSysNotifyModel model){
        return false;
    }

    // 根据策略名称执行相应的策略
    public TradeSysNotify getNotifyService(String notifyChannel) {
        TradeSysNotify strategy = notifyMap.get(notifyChannel);
        if (strategy != null) {
            return strategy;
        } else {
            log.error("未找到通知的方式, notifyChannel:{}", notifyChannel);
        }
        return null;
    }
}
